<template>
  <el-table :data="list" border table-layout="auto">
    <el-table-column prop="id" label="编号" />
    <el-table-column prop="name" label="资源名称" />
    <el-table-column prop="url" label="资源路径" />
    <el-table-column prop="description" label="描述" />
    <el-table-column label="添加时间" prop="createTime">
      <template #default="{ row }">
        <span>{{ formateDate(row.createTime) }}</span>
      </template>
    </el-table-column>
  </el-table>
  <ElConfigProvider :locale="zhCn">
    <div class="page">
      <el-pagination
        v-model:current-page="pageNum"
        v-model:page-size="pageSize"
        :page-sizes="[10, 20, 50, 100]"
        background
        layout="total, sizes, prev, pager, next, jumper"
        :total="total"
        @size-change="pageChangeHandle"
        @current-change="pageSizeChangeHandle"
      />
    </div>
  </ElConfigProvider>
</template>
<script setup lang="ts">
import zhCn from "element-plus/es/locale/lang/zh-cn";
import { formateDate } from "@/utils";
import useTable from "@/hooks/useTable";
import { getResourceListApi } from "./api";
import { reactive } from "vue";
const id = reactive({
  id: 0,
});
const {
  list,
  pageNum,
  pageSize,
  total,
  pageChangeHandle,
  pageSizeChangeHandle,
} = useTable(getResourceListApi, id);
</script>
<style lang="less" scoped>
:deep(.cell) {
  text-align: center !important;
}
.page {
  padding: 20px;
  display: flex;
  justify-content: flex-end;
}
</style>
